package com.uzai.console.component;

import com.doudian.open.core.GlobalConfig;
import com.uzai.common.enums.RedisCacheKeyEnum;
import com.uzai.console.config.UzaiConsoleSysConfig;
import groovy.util.logging.Log4j;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

/**
 * 项目启动加载类
 * @author liuqi
 * @date 2022年04月19日 10:47
 */
@Component
@Slf4j
public class SysInit {

    @Autowired
    private UzaiConsoleSysConfig uzaiConsoleSysConfig;
    @Autowired
    private RedisTemplate redisTemplate;

    @PostConstruct
    public void defaultMerInit(){

        log.info("---进入系统初始化配置---");

        //初始化系统默认运营商
        redisTemplate.opsForValue().set(RedisCacheKeyEnum.SYS_DEFAULT_MERID.getKey(), uzaiConsoleSysConfig.getDefaultMerId());

        //初始化抖音配置
        GlobalConfig.initAppKey(uzaiConsoleSysConfig.getDyTokenAppkey());
        GlobalConfig.initAppSecret(uzaiConsoleSysConfig.getDyTokenAppsecret());

    }
}
